Simple Start of Program using multiple windows - wont run

by: justin2405, 7 years ago


So I started to watch the Programming GUIs with tkinter series, as it was going to teach exactly what I needed. But I copied the code almost exactly in the video and it won't run. Anyone see where I went wrong?



import tkinter as tk

class gtracker(tk.Tk):

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)

        container=tk.Frame(self)

        container.pack(side="top",fill="both",expand=True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (StartPage):

            frame = F(container, self)

            self.frames[F] = frame

            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()

class StartPage(tk.Frame):

    def __init__(self,parent,controller):
        tk.Frame.__init__(self,parent)
        label=tk.Label(self,text="Welcome to gtracker")
        label.pack(pady=10,padx=10)


app = gtracker()
app.mainloop()






You must be logged in to post. Please login or register an account.



You should provice a description what exactly doesn't work and what error messages you receive. Your code wouldn't produce any window, because you are iterating over a class. How should python know how many frames you want? and why are you using F as a key in your dictionary?

-quizzmaster 7 years ago

You must be logged in to post. Please login or register an account.